/**
 * 
 */
package hr.fer.zemris.annotator.model;

import hr.fer.zemris.annotator.exceptions.ProgramNotSelectedException;
import hr.fer.zemris.annotator.exceptions.ProgramSourceNotSelectedException;
import hr.fer.zemris.annotator.model.interfaces.IApplicationParameters;

/**
 * @author dajan
 * 
 */
public class ApplicationParameters implements IApplicationParameters {

	private String compiledProgramPath;
	private String outputPath;
	private String sourcePath;
	private String compiledProgramName;

	private static ApplicationParameters instance = null;

	public String getCompiledProgramName() {
		return compiledProgramName;
	}

	public void setCompiledProgramName(String compiledProgramName) {
		this.compiledProgramName = compiledProgramName;
	}

	public ApplicationParameters() {
		compiledProgramPath = "";
		outputPath = "";
		sourcePath = "";
		compiledProgramName = "";
	}

	public void prepareParameters() {
		compiledProgramPath.trim();
		compiledProgramName.trim();
		outputPath.trim();
		sourcePath.trim();
	}

	public boolean validateParameters() throws ProgramNotSelectedException,
			ProgramSourceNotSelectedException {

		boolean validated = true;

		if (compiledProgramPath.equals("") || compiledProgramPath == null) {
			throw new ProgramNotSelectedException(
					"Compiled program is not selected!");

		}

		if (compiledProgramName.equals("") || compiledProgramName == null) {
			throw new ProgramNotSelectedException(
					"Compiled program is not selected!");

		}

		if (sourcePath.equals("") || sourcePath == null) {
			throw new ProgramSourceNotSelectedException(
					"Program source is note selected!");
		}

		if (outputPath.equals("") || outputPath == null) {
			validated = false;
		}

		return validated;

	}

	public static ApplicationParameters getInstance() {
		if (instance == null) {
			instance = new ApplicationParameters();
		}
		return instance;
	}

	public String getCompiledProgramPath() {
		return compiledProgramPath;
	}

	public void setCompiledProgramPath(String compiledProgramPath) {
		this.compiledProgramPath = compiledProgramPath;
	}

	public String getOutputPath() {
		return outputPath;
	}

	public void setOutputPath(String outputPath) {
		this.outputPath = outputPath;
	}

	public String getSourcePath() {
		return sourcePath;
	}

	public void setSourcePath(String sourcePath) {
		this.sourcePath = sourcePath;
	}

}
